package restless.core.managers {
	
	import com.greensock.TimelineLite;
	import com.greensock.TimelineMax;
	import restless.core.gameObjs.RLEUpdateRenderObj;
	
	/**
	 * @author Jordan Laine
	 * @date 03/25/13
	 */
	
	public class RLETweenManager extends RLEUpdateRenderObj {
		private var nIndex:int;
		private var urTimeline:TimelineMax;
		private var tempTimelineLite:TimelineLite;
		private var tempTimelineMax:TimelineMax;
		
		private var vTimelineLite:Vector.<TimelineLite>;
		private var vTimelineLiteIDs:Vector.<String>;
		private var vTimelineMax:Vector.<TimelineMax>;
		private var vTimelineMaxIDs:Vector.<String>;
		
		public function RLETweenManager (tl:TimelineMax) {
			setRE();
			urTimeline = tl;
			vTimelineLite = new Vector.<TimelineLite>;
			vTimelineMax = new Vector.<TimelineMax>;
			vTimelineMaxIDs = new Vector.<String>;
			vTimelineLiteIDs = new Vector.<String>;
		}
		
		public function getURTimeline():TimelineMax {
			return urTimeline;
		}
		
		public function newTimelineMax(id:String, autoRemove:Boolean = true):TimelineMax {
			tempTimelineMax = new TimelineMax( { useFrames:true, autoRemoveChildren:autoRemove } );
			vTimelineMaxIDs.push(id);
			vTimelineMax.push(tempTimelineMax);
			return tempTimelineMax;
		}
		
		public function getTimelineMax(id:String):TimelineMax {
			nIndex = vTimelineMaxIDs.indexOf(id);
			tempTimelineMax = vTimelineMax[nIndex];
			return tempTimelineMax;
		}
		
		public function newTimelineLite(id:String, autoRemove:Boolean = true):TimelineLite {
			tempTimelineLite = new TimelineMax( { useFrames:true, autoRemoveChildren:autoRemove } );
			vTimelineLite.push(tempTimelineLite);
			vTimelineLiteIDs.push(id);
			return tempTimelineLite;
		}
		
		public function getTimelineLite(id:String):TimelineLite {
			nIndex = vTimelineLiteIDs.indexOf(id);
			tempTimelineLite = vTimelineLite[nIndex];
			return tempTimelineLite;
		}
	}
}